// JavaScript Document
var Fjs=function(){
	function addEvent(obj,eventtype,listener){
		if(obj.addEventListener){
			obj.addEventListener(eventtype,listener,false)
			return true
			}else if(obj.attachEvent){
				obj['e'+eventtype+listener] = listener;
				obj[eventtype+listener]=function(){
					obj['e'+eventtype+ listener](window.event);
				}
				obj.attachEvent('on'+eventtype,obj[eventtype+listener]);
				return true ;
			}
			return false;
	}
	function  removeEvent(obj,eventtype,listener){
		if (obj.removeEventListener){
			obj.removeEventListener(eventtype,listener,false);
			return true;
		}else if(obj.detachEvent){
			obj.detachEvent('on'+type,node[eventtype + listener]); 
			obj[eventtype+listener]=null;
			return true ;
		}
		return false ;
	}
	//prevent default event and bubbling
	function stopEvent(e){
		e = e || window.event;
		if(e.preventDefault) {
			e.preventDefault();
			e.stopPropagation();
		}else{
			e.returnValue = false;
			e.cancelBubble = true;
		}
	}
	//prevent bubbling
	function stopPropagation(e) {
		e = e || window.event;
		if (!+"\v1") {
			e.cancelBubble = true;
		} else {
			e.stopPropagation();
		}
	}
	//prevent default event
	function preventDefault(e) {
		e = e || window.event;
		if(e.preventDefault) {
		  e.preventDefault();
		}else{
		  e.returnValue = false;
		}
	}
	//get event source
	function getEventTarget(e){
	  e = e || window.event;
	  var target = e.srcElement ? e.srcElement : e.target;
	  return target;
	}
	// onpropertychange event
	function addPropertyChangeEvent(obj,fn) {
		if(window.ActiveXObject){
			obj.onpropertychange = fn;
		}else{
			obj.addEventListener("input",fn,false);
		}
	}
	//get mouse position
	function mousePosition(evt){  
		var evt = evt || window.event;  
		//Mozilla  
		if(evt.pageX || evt.pageY){  
			return { x : evt.pageX,y : evt.pageY};     
		}  
		//IE  
		return {  
			x : evt.clientX + document.body.scrollLeft - document.body.clientLeft,  
			y : evt.clientY + document.body.scrollTop - document.body.clientTop  
		};
	} 
	function getById(elem){
		if(typeof elem === 'string'){
			return document.getElementById(elem);
		}
		return elem;
	}
	
	// html select 
	var selectHTML={
		add:function(obj,optlab,optval){
			obj.options[obj.length] = new Option(optlab, optval);
		},
		setDefalut:function(obj,defaultval){
			var len=obj.length;
			for(i=0;i<len;i++){
				if(obj.options[i].value==defaultval){
					obj.options[i].selected=true;
					return;
				}
			}
		}
	}
	function getOffsetPosition(elem){
	  if ( !elem ) return {left:0, top:0};
	  var top = 0, left = 0;
	  if ( "getBoundingClientRect" in document.documentElement ){
		var box = elem.getBoundingClientRect(),
		doc = elem.ownerDocument,
		body = doc.body,
		docElem = doc.documentElement,
		clientTop = docElem.clientTop || body.clientTop || 0,
		clientLeft = docElem.clientLeft || body.clientLeft || 0,
		top  = box.top  + (self.pageYOffset || docElem && docElem.scrollTop  || body.scrollTop ) - clientTop,
		left = box.left + (self.pageXOffset || docElem && docElem.scrollLeft || body.scrollLeft) - clientLeft;
	  }else{
		do{
		  top += elem.offsetTop || 0;
		  left += elem.offsetLeft || 0;
		  elem = elem.offsetParent;
		} while (elem);
	  }
	  return {left:left, top:top};   
	}
	return{
		addEvent:addEvent,
		removeEvent:removeEvent,
		preventDefault:preventDefault,
		getId:getById,
		mousePosition:mousePosition,
		selectHTML:selectHTML,
		getAbsPosition:getOffsetPosition,
		getEventTarget:getEventTarget,
		stopPropagation:stopPropagation
	}
}();
Date.prototype.format=function(formatstr){
	if(!formatstr) return this;
	var o = { 
		"M+" : this.getMonth()+1, //month 
		"d+" : this.getDate(), //day 
		"h+" : this.getHours(), //hour 
		"m+" : this.getMinutes(), //minute 
		"s+" : this.getSeconds(), //second 
		"q+" : Math.floor((this.getMonth()+3)/3), //quarter 
		"S" : this.getMilliseconds() //millisecond 
	} 

	if(/(y+)/.test(formatstr)) { 
		formatstr = formatstr.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	} 

	for(var k in o) { 
		if(new RegExp("("+ k +")").test(formatstr)) { 
			formatstr = formatstr.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); 
		} 
	} 
	return formatstr; 
}


var selectObj=function(){
	function append(obj,optlab,optval,repeat){
		if(repeat){
			obj.options[obj.length] = new Option(optlab, optval);
		}else{
			if(exists(obj,optval)===-1){
				obj.options[obj.length] = new Option(optlab, optval);
			}
		}
	}
	function fill(obj,dataary,repeat,clear){
		if(clear) obj.length=0;
		if(!isArray(dataary)) return false;
		var len=dataary.length;
		for(var i=0;i<len;i++){
			if(isArray(dataary[i])){
				append(obj,dataary[i][1],dataary[0],repeat);
			}else{
				append(obj,dataary[i],dataary[i],repeat);
			}
		}
	}
	function exists(obj,value){
		var len=obj.length;
		for(var i=0;i<len;i++){
			if(obj.options[i].value===value){
				return i;
			}
		}
		return -1;
	}
	function getSelected(obj){
		var ret=[];
		var len=obj.length;
		for(var i=0;i<len;i++){
			if(obj.options[i].selected){
				ret.push(obj.options[i].value);
			}
		}
		return ret;
	}
	function getOptions(obj){
		var ret=[];
		var len=obj.length;
		for(var i=0;i<len;i++){
			ret.push(obj.options[i].value);
		}
		return ret;
	}
	function removeSelected(obj){
		var len = obj.length - 1;    
		for(var i = len; i >= 0; i--){    
			if(obj[i].selected == true){    
				obj.options.remove(i);    
			}    
		}    
	}
	function removeItem(obj,value){
		var len=obj.length;
		if (exists(obj, value)>-1) {        
			for (var i = 0; i < len; i++) {        
				if (obj.options[i].value == value) {        
					obj.options.remove(i);        
					break;        
				}        
			}              
    	}       
	}
	function remove(obj,value){
		if(value){
			removeItem(obj,value)
		}else{
			removeSelected(obj);
		}
	}
	function removeAll(obj){
		obj.length=0;
	}
	function setDefalut(obj){
		var len=obj.length;
		var arglen=arguments.length;
		if(arglen<=1) return;
		if(arglen>1){
			var arg=Array.apply(this,arguments);
			for(var i=1;i<arglen;i++){
				if(exists(obj,arg[i])>-1){
					obj.options[exists(obj,arg[i])].selected=true;
				}
			}
		}
	}
	function isArray(obj){
		return Object.prototype.toString.call(obj)==='[object Array]'
	}
	return{
		append:append,
		fill:fill,
		getSelected:getSelected,
		getOptions:getOptions,
		remove:remove,
		removeAll:removeAll,
		setDefalut:setDefalut
	}
}();
var mask=function(){
	function createmask(){
		
	}
	function showmask(){
		
	}
	function closemask(){
		
	}
	function resizemask(){
		
	}
	return{
		show:showmask,
		close:closemask
	}
}();
var tip=function(){
	function createtip(){
	}
	function showtip(){
	}
	function closetip(){
	}
	return{
		show:showtip,
		close:closetip
	}
}();
var dataTable=function(opt){
	var opt=opt||option
	var odocument=document.createDocumentFragment();
	function createHead(opt){}
	function createBody(opt){}
	this.showTable=function(data){
		createHead(opt);
		createBody(opt);
	}
	
}